
#ifndef SCOREMANAGER_H
#define SCOREMANAGER_H

#include "Singleton.h"
#include "TextEntity.h"
#include "RenderableEntity.h"
#include "TimeLineEffect.h"
#include "ScaleEffect.h"
#include "ParticleSystem.h"
#include "BezierCurve.h"


const int SUCCESS_TEXTS = 2;

class ScoreManager : public Singleton<ScoreManager>
{
    
private:
    RenderableEntity *m_eBabiesIcon;
    RenderableEntity *m_eCoinsIcon;
    RenderableEntity *m_eChainHolder;
    RenderableEntity *m_eRainbow;
    
    // success texts
    RenderableEntity *m_oaSuccessTexts[SUCCESS_TEXTS];
    RenderableEntity* m_oChainText;
    int m_iCurrentText;
    float m_fTimeSinceLastSuccess;
    float m_fSuccesTextTime;
    
	TextEntity	*m_tBabiesText;
	TextEntity	*m_tCoinsText;
	TimeLineEffect *m_eCoinsAnim;
    
 	TextEntity	*m_tChain;
	ScaleEffect *m_eChainScaleBig;
	ScaleEffect *m_eChainScaleSmall;
	TimeLineEffect *m_eChainScale;
    
	RenderableEntity *m_eBabyParticle;
	TimeLineEffect *m_eBabyParticleMove;
	
	TextEntity *m_eNumerito;
	TimeLineEffect *m_eNumeritoAnim;
	bool m_bNumeritoStarted;
	
    bool m_bScoreVisible;
    
	int m_iCoins;
	int m_iCoinsToShow;
    
    float m_fBarProgress;
    float m_fBarProgressTarget;
    int m_iChain;
    
    ParticleSystem* m_oRainbowEdge;
    ParticleSystem* m_oFullChain;
    ParticleSystem* m_oAddChainParticles;
    BezierCurve* m_oRainbowCurve;
	
public:
	ScoreManager() {}
	~ScoreManager();

    void initRainbow(float _fTotal) { m_fBarProgress = 0.1f; m_fBarProgressTarget = _fTotal; }
    void setBarProgress(float _value) { m_fBarProgressTarget = _value; }
    
	void init();
	void update(float dt);
	void render();
    void renderRainbow();
    void renderSuccessTexts();
    
    void startGame();
    void showScore(bool _bVisible = true);

    void setBabies(int _iBabies);
    void setCoins(int _iCoins, Vector2 _vPos);
	
	void addBaby(Vector2 _vPos);
	void addCoins(int _iNumCoins, Vector2 _vPos);
    void setChainMultiplier(int _iMultiplier, bool _bPowerUp);
    float getRainbowProgress() { return m_fBarProgress; }
};

#endif
